<?php
/*
|--------------------------------------------------------------------------
| Wechat Routes
|--------------------------------------------------------------------------
|
| 这里存放微信相关接口
|
*/

use Illuminate\Support\Facades\Route;

//微信接口服务
Route::any('wechat/server', 'Wechat\\ServerController@server')->name('server');
//小程序支付回调地址
Route::any('wechat/notify', 'Wechat\\ServerController@wechatNotify')->name('payment.wechat.notify');
Route::any('wechat/fee_notify', 'Wechat\\ServerController@FeeNotify')->name('payment.wechat.fee_notify');
Route::any('wechat/pay_notify', 'Wechat\\ServerController@payNotify')->name('payment.wechat.pay_notify');

Route::namespace('Wechat')->prefix('wechat')->group(function () {

    Route::post('register', 'ServerController@register');
    //根据code换取session信息
    Route::get('getUserInfoByCode/{code}', 'PublicController@getUserInfoByCode');

    //通过ID获取用户信息
    Route::get('getUserData/{id}', 'ServerController@getUserData');

    //获取省市区联动
    Route::get('areaLists', 'PublicController@areaLists')->name('areaLists');
    //获取所有小区
    Route::get('allCommunity/{province_id}/{city_id}/{area_id}', 'PublicController@allCommunity');
    //获取小区的所有楼栋
    Route::get('allHouse/{id}', 'PublicController@getAllHouseByCommunity');
    //获取楼栋的所有单元
    Route::get('allElement/{id}', 'PublicController@getAllElementByHouse');
    //获取单元的所有楼层
    Route::get('allFloor/{id}', 'PublicController@getAllFloorByElement');
    //获取单元的所有房间
    Route::get('allRoom/{id}', 'PublicController@getAllRoomByFloor');
    //发送短信
    Route::get('send_sms', 'ServerController@send_sms');

    Route::get('getNavList', 'PublicController@getNavList');//获取导航列表
    Route::get('getIndexCateList', 'PublicController@getIndexCateList');//获取类目列表
    Route::get('getFleaGoods', 'FleaGoodsController@getFleaGoods');//获取跳蚤市场商品列表

    Route::group(['middleware' => 'jwt.user'], function () {

        Route::group(['prefix' => 'operation'], function () {
            Route::get('getHomeBannerList', 'OperationController@getHomeBannerList');// 首页轮播图
            Route::get('getResourcesList', 'OperationController@getResourcesList'); //首页资源位
        });

        //资源路由
        /*Route::apiResource([
            'flea_goods' =>[ 'FleaGoodsController', 'only' => ['store','edit','index']]// 闲置商品
        ]);*/
        //资源路由
        Route::apiResource('flea_goods', 'FleaGoodsController', ['only' => ['store', 'edit', 'index', 'show', 'destroy']]);
        Route::get('sale_goods/{id}', 'FleaGoodsController@update_sale');

        Route::get('fleaMsgIndex', 'FleaMsgController@index');
        Route::post('addFleaMsg', 'FleaMsgController@add_msg');
        //修改手机号
        Route::post('changePhone', 'ServerController@changePhone');
        //用户评论
        Route::post('getComments', 'ServerController@getComments');

    });

});

//微信支付测试
Route::any('wechat/pay', 'Wechat\\PayController@pay');
